package com.wang.friend.controller;

import com.wang.friend.domain.question.dto.QuestionQueryDTO;
import com.wang.friend.domain.question.vo.QuestionDetailVO;
import com.wang.friend.service.IQuestionService;
import com.wang.common.core.domain.R;
import com.wang.common.core.domain.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "题目功能接口")
@RequestMapping("/question")
@RestController
public class QuestionController {

    @Autowired
    private IQuestionService questionService;

    @Operation(
            summary = "以游客身份查询题目列表",
            description = "根据关键字或难度从ES中查询当前页面的题目列表")
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return questionService.list(questionQueryDTO);
    }

    @Operation(summary = "获取指定题目的详细信息")
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId){
        return R.success(questionService.detail(questionId));
    }

    @Operation(summary = "获取前一个题目的id")
    @GetMapping("/preQuestion")
    public R<String> preQuestion(Long questionId){
        return R.success(questionService.preQuestion(questionId));
    }

    @Operation(summary = "获取后一个题目的id")
    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long questionId){
        return R.success(questionService.nextQuestion(questionId));
    }
}
